home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Dialectic 1.2 / source / Dialectic ƒ / Raw dialects ƒ / op.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.2 KB  |  87 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        op.c
  4.  
  5. Purpose:    This module handles actually converting text into Op.
  6.  
  7.  
  8. Dialectic -=- dialect text conversion extraordinare
  9. Copyright ©1994, Mark Pilgrim
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "dialectic dispatch.h"
  29. #include "dialectic utilities.h"
  30. #include "program globals.h"
  31.  
  32. void ConvertOp(void)
  33. {
  34.     Str255            thisWord, thatWord;
  35.     int                i;
  36.     int                origLength;
  37.     Boolean            firstIsCaps;
  38.     Boolean            isAllCaps;
  39.     Boolean            lookingForVowel;
  40.     Boolean            justGotQ;
  41.     
  42.     if (!IsAlpha(ThisChar()))
  43.     {
  44.         StoreChar(ThisChar());
  45.         InputPlus(1);
  46.         return;
  47.     }
  48.     
  49.     origLength=GetRestOfWord(thisWord);
  50.     if (thisWord[0]==0x00)    return;
  51.     
  52.     firstIsCaps=IsUpperAlpha(thisWord[1]);
  53.     isAllCaps=IsAllCaps(thisWord);
  54.     
  55.     thatWord[0]=0x00;
  56.     lookingForVowel=TRUE;
  57.     justGotQ=FALSE;
  58.     for (i=1; i<=origLength; i++)
  59.     {
  60.         if ((IsVowel(thisWord[i])) || ((thisWord[i]|0x20)=='y'))
  61.         {
  62.             if ((lookingForVowel) && (!justGotQ))
  63.             {
  64.                 thatWord[++thatWord[0]]=isAllCaps ? 'O' : 'o';
  65.                 thatWord[++thatWord[0]]=isAllCaps ? 'P' : 'p';
  66.                 lookingForVowel=FALSE;
  67.             }
  68.             justGotQ=FALSE;
  69.         }
  70.         else
  71.         {
  72.             lookingForVowel=TRUE;
  73.             justGotQ=((thisWord[i]|0x20)=='q');
  74.         }
  75.         
  76.         thatWord[++thatWord[0]]=thisWord[i];
  77.         if ((i==1) && (!isAllCaps) && (thisWord[1]>='A') && (thisWord[1]<='Z'))
  78.             thatWord[thatWord[0]]|=0x20;
  79.     }
  80.     
  81.     if ((firstIsCaps) && (thatWord[1]>='a') && (thatWord[1]<='z'))
  82.         thatWord[1]&=0xdf;
  83.  
  84.     StoreString(thatWord);
  85.     InputPlus(origLength);
  86. }
  87.